package cn.jinjie.day06.menu2;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class Test02 {
    public static void main(String[] args) {
        Set<Student> s = new TreeSet<>();
        s.add(new Student("lisi", 26));
        s.add(new Student("laaos", 18));
        s.add(new Student("zhangs", 25));
        s.add(new Student("wang", 20));
        s.add(new Student("liu", 12));
        s.add(new Student("li", 18));
        s.add(new Student("mm", 36));
        System.out.println(s);
        Set<Student> s1 = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o2.getAge() - o1.getAge();
            }
        });
        s1.add(new Student("lisi", 26));
        s1.add(new Student("laaos", 18));
        s1.add(new Student("zhangs", 25));
        s1.add(new Student("wang", 20));
        s1.add(new Student("liu", 12));
        s1.add(new Student("li", 18));
        s1.add(new Student("mm", 36));
        System.out.println(s1);
    }
}
